<?php
require_once("database.php");
class xl_class extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from class limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from class";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($clid)
	{
		
		$sql = "select * from class where clid = '$clid'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function xoa($clid, $from_uid)
	{
		
		$sql = "delete from class where clid = '$clid', from_uid = '$from_uid'";
		$this->setQuery($sql);
		$this->query();
	}
	function them($clname)
	{
		$clname = addslashes($clname);

		$sql = "INSERT INTO class(clname) VALUES ('$clname')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($clid, $clname, $from_uid)
	{
		$clname = addslashes($clname);

		$sql ="UPDATE class SET clname= '$clname' WHERE clid = '$clid', from_uid = '$from_uid'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from class where	$clname like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>